home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c
- Subject: Re: Help:what is wrong this code?
- Date: 10 Apr 1996 15:21:25 GMT
- Organization: Borland International
- Message-ID: <4kgjll$6lm@druid.borland.com>
- References: <4k3p3q$n76@brahms.udel.edu> <4k4hi3$5hm@sparcserver.lrz-muenchen.de> <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>,
- n9341884@henson.cc.wwu.edu says...
- >
- >
- >
- >On 6 Apr 1996, Kurt Watzka wrote:
- >
- >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
- >>
- >>
- >> >Why it give me 0.0000?
- >>
- >> >#include <stdio.h>
- >> >main () {
- >> >double a=9.008;
- >> >printf("%f\n",sqrt(a));
- >> >return 0;
- >> >}
- >
- >
- >
- >
- >your printf specifer needs to be "%lf", not "%f", since a is a double
- >
- >
-
- No. Floats are promoted to doubles when they are passed in a variable arguments
- list, as in printf, and %f is the correct format specifier. It indicates an
- argument of type double. The problem is that there is no prototype for sqrt(),
- so the compiler assumes that it returns an int.
-
-